//    Copyright (C) Clear Office.  All rights reserved.
using System;
using Office.Core.Serialization;

namespace Office.Spreadsheet.PivotTable
{
    internal class ChartFormat : IOfficeXmlSerializable
    {
        private const string xmlName = "chartFormat";
        private Int32 _chart;
        private Int32 _format;
        private PivotArea _pivotArea;
        private Boolean _series;

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read(xmlName))
            {
                _chart = c.GetUIntegerAsInteger("chart");
                _format = c.GetUIntegerAsInteger("format");
                _series = c.GetOptionalBoolean("series", false);
                _pivotArea = c.ReadOptionalElement<PivotArea>("pivotArea");
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write(xmlName))
            {
                c.SetUIntegerAsInteger("chart", _chart);
                c.SetUIntegerAsInteger("format", _format);
                c.SetOptionalBoolean("series", _series, false);
                c.WriteOptionalElement(_pivotArea);
            }
        }

        #endregion
    }
}